package com.chinaunicom.emergency.service;

import com.chinaunicom.emergency.model.YjglOrg;
import com.chinaunicom.emergency.repository.OrgRepository;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;

/**
 * @author liliang
 * @date 2019-12-13
 */
@Service
@Log4j2
public class BaseService {

    @Autowired
    private OrgRepository orgRepository;


    public String getDeptNameByUser(String orgId) {
        if (StringUtils.isBlank(orgId)) {
            return "";
        }
        List<String> orgIds = Arrays.asList(orgId.split(","));
        List<YjglOrg> orgs = orgRepository.findByOrgIdInAndIsSoftDel(orgIds, 0);
        StringBuffer sb = new StringBuffer();
        for (YjglOrg org : orgs) {
            sb.append(org.getOrgName() + ",");
        }
        if (sb.length() > 0) {
            sb.setLength(sb.length() - 1);
        }
        return sb.toString();
    }



    public static void main(String[] args) throws ExecutionException, InterruptedException {
        List<String> memberList = new ArrayList<>();
        memberList.add("1");
        memberList.add("2");
        memberList.add("3");
        memberList.add("4");
        memberList.add("5");
        memberList.add("6");
        memberList.add("7");
        memberList.add("8");
        memberList.add("9");
        memberList.add("10");
        memberList.add("11");
        memberList.add("12");
//        saveMemberReadData(memberList, "121");
    }

}
